#include <util/Utility.h>
#include <gtest/gtest.h>

using namespace util;

TEST(TestUtility, testMostPresentValue1)
{
  std::vector<int> v(10);

  ASSERT_TRUE(*Utility::mostPresentValue(v.begin(), v.end()) == 0);
}

TEST(TestUtility, testMostPresentValue2)
{
  std::vector<int> v(10);
  v[0] = 1;
  v[1] = 1;
  v[2] = 1;
  v[3] = 1;
  v[4] = 1;
  v[5] = 1;

  ASSERT_TRUE(*Utility::mostPresentValue(v.begin(), v.end()) == 1);
}

TEST(TestUtility, testMostPresentValue3)
{
  std::vector<int> v(10);
  v[0] = 4;
  v[1] = 3;
  v[2] = 2;
  v[3] = 1;
  v[4] = 0;
  v[5] = 5;
  v[6] = 5;
  v[7] = 5;
  v[8] = 5;
  v[9] = 5;

  ASSERT_TRUE(*Utility::mostPresentValue(v.begin(), v.end()) == 5);
}

TEST(TestUtility, testMostPresentValue4)
{
  std::vector<int> v(10);
  v[0] = 4;
  v[1] = 4;
  v[2] = 4;
  v[3] = 3;
  v[4] = 3;
  v[5] = 3;
  v[6] = 2;
  v[7] = 2;
  v[8] = 1;
  v[9] = 0;

  ASSERT_TRUE(*Utility::mostPresentValue(v.begin(), v.end()) == 3
          || *Utility::mostPresentValue(v.begin(), v.end()) == 4);
}

TEST(TestUtility, testMostPresentValue5)
{
  std::vector<int> v(10);
  v[0] = 1;
  v[1] = 2;
  v[2] = 3;
  v[3] = 1;
  v[4] = 2;
  v[5] = 3;
  v[6] = 1;
  v[7] = 2;
  v[8] = 3;
  v[9] = 1;

  std::vector<int>::const_iterator begin = v.begin();
  std::vector<int>::const_iterator end = v.end();
  ASSERT_TRUE(*Utility::mostPresentValue(begin, end) == 1);
}
